<template>
	<view class="">
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view v-for="(item, index) in activityList" :key="item.activityId">
				<activity-cell 
				:activityType="item.activityType" 
				:activityTitle="item.activityName"
				:applyCount="item.inventedSalesNumber"
				:isReferralBonuses = "item.isReferralBonuses"
				:finishTime="item.timeEnd"
				:activityId="item.activityId"
				:activityUrl="item.coverImage | imageUrl"
				></activity-cell>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import activityCell from '@/components/activity/activity-cell.vue'
	import {apiActivityList} from '@/api/marketing-api.js'
	import GLOBAL_CONFIG from '@/settings.js';
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
			activityCell
		},
		data() {
			return {
				activityList: []
			}
		},
		filters:{
			imageUrl(url) {
				return GLOBAL_CONFIG.baseImageUrl + url;
			},
		},
		onLoad() {
		
		},
		methods: {
			upCallback(page) {
				apiActivityList({
					tenantId : this.$store.state.user.tenantId,
					businessNo : this.$store.state.order.businessNo,
					pageNo : page.num,
					pageSize: page.size,
				}).then(res => {
					this.mescroll.endSuccess(res.data.length);
					//设置列表数据
					if (page.num == 1) this.activityList = []; //如果是第一页需手动制空列表
					this.activityList = this.activityList.concat(res.data); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
		
		}
	}
</script>

<style>
</style>
